Repository navigation
plugin: write the Windows te launcher with LF endings and forward slashes - #241
Open
Tanmay Shah (TanmayShah29) wants to merge 1 commit into
Open
Tanmay Shah (TanmayShah29) wants to merge 1 commit into
Tanmay Shah (TanmayShah29) wants to merge 1 commit into
Conversation
…shes On Windows, ensure_launcher wrote ~/.tokeneconomizer/bin/te in text mode, so its lines ended in CRLF and sh handed each command a stray "\r" argument. The check that skips an unchanged launcher read it back in text mode too, which hid the CRLF, so a broken launcher was never repaired. The launcher also exec'd scripts/te by a backslash path, which the shell omp runs commands in cannot run, and scripts/te finds its own directory with a cd inside $(...), which that shell refuses (reported in microsoft#167). Write and compare the launchers with newline="\n" and newline="", so a CRLF copy left by an earlier version is replaced. On Windows, bin/te now runs what te.json already names for PowerShell, with forward slashes: the Python the hook runs under and te_bootstrap.py, with TE_CORE_PATH set to the package the hook imported unless the person set it. The POSIX launcher is unchanged. This follows the fix proposed by tejasach06 in microsoft#167. The issue's second point (the lib/tokeneconomizer symlink checked out as a plain file in the installed copy) still affects the hooks and is not changed here. Refs microsoft#167
|
Tanmay Shah (@TanmayShah29) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #167
This implements the fix tejasach06 proposed in #167, which you asked for on 2026-11-08. I picked it up after a week with no PR; I am happy to close this in favour of theirs if they open one.
What changed
ensure_launcherwrites the launchers withnewline="\n"and compares them withnewline="". On Windows, text mode had givenbin/teCRLF endings (soshpassed a stray\rargument), and the text-mode compare hid them, so a broken launcher was never repaired. A CRLF copy left by an earlier version is now replaced.bin/teruns whatte.jsonalready names for PowerShell, with forward slashes: the Python the hook runs under andte_bootstrap.py, withTE_CORE_PATHset to the package the hook imported unless it is already set. This avoidsscripts/te, whose backslashexecpath andcdinside$(...)the shell omp runs commands in cannot handle._WINDOWSflag lets the tests write the Windows launcher on any system.Behaviour change on Windows:
teno longer re-readsTE_PYTHONon each run. It uses the Python the hook last ran under, aste.jsondoes; the launcher is rewritten at every session start and prompt.Not in this PR: the issue's second point (
lib/tokeneconomizerchecked out as a plain file in the installed copy) still affects the hooks. SettingTE_CORE_PATHonly coverste.Tests
tests/test_windows_launcher.py: a CRLF launcher is rewritten with LF; the exact launcher text on POSIX and on Windows (forward slashes, quoted path with a space); and the Windows launcher runste config setthroughsh. All of them fail against the currentpaths.py.python -m pytest tests experiments/tests: 1561 passed, 34 skipped (Linux, Python 3.10).